package com.liukai.novel_base.base;


import android.content.Context;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import butterknife.ButterKnife;
import butterknife.Unbinder;

public abstract class BaseActivity extends AppCompatActivity {

    private Unbinder mBind;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLayoutId());
        mBind = ButterKnife.bind(this);
        initData(this);
        initView();
        initListener();
    }

    /**
     * 获取布局Layout的Id
     * @return
     */
    protected abstract int getLayoutId();

    /**
     * 初始化数据
     */
    protected abstract void initData(Context context);

    /**
     * 初始化组件
     */
    protected abstract void initView();


    /**
     *
     * 初始化监听器
     */
    protected abstract void initListener();


    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (mBind != null) {
            mBind = null;
        }
        release();
    }

    /**
     * 销毁Activity释放资源
     */
    protected void release(){

    }


}
